package services;

import dao.UserDao;
import entity.User;
import util.EncryptUtil;

/**
 * @program: personnel_management_system
 * @description: login user
 * @author: Mr.Sun
 * @create: 2020-06-18 23:22
 **/

public class UserService {
    public boolean isUser(String name,String pwd) throws Exception {
        boolean res = false;
        UserDao udao = new UserDao();
        User user = udao.selectByName(name);
        if(user != null){
            String salt = user.getSalt();
            String password = EncryptUtil.md5(salt+pwd);
            res = user.getPassword().equals(password);
            System.out.println("check user result:"+res);
        }
        return res;
    }
}
